-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc++][NFC] Refactor __is_allocator to be a variable template #159584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ With the latest revision this PR passed the C/C++ code formatter. |
fa0cfde
to
1292b36
Compare
1292b36
to
fb551a0
Compare
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesPatch is 93.17 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/159584.diff 19 Files Affected:
diff --git a/libcxx/include/__flat_map/flat_map.h b/libcxx/include/__flat_map/flat_map.h
index bf193f6d3c62f..31ba9bc0b91ac 100644
--- a/libcxx/include/__flat_map/flat_map.h
+++ b/libcxx/include/__flat_map/flat_map.h
@@ -1125,8 +1125,7 @@ class flat_map {
};
template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>>
- requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
- !__is_allocator<_MappedContainer>::value &&
+ requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> &&
is_invocable_v<const _Compare&,
const typename _KeyContainer::value_type&,
const typename _KeyContainer::value_type&>)
@@ -1139,7 +1138,7 @@ flat_map(_KeyContainer, _MappedContainer, _Compare = _Compare())
template <class _KeyContainer, class _MappedContainer, class _Allocator>
requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
- !__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value)
+ !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer>)
flat_map(_KeyContainer, _MappedContainer, _Allocator)
-> flat_map<typename _KeyContainer::value_type,
typename _MappedContainer::value_type,
@@ -1148,9 +1147,8 @@ flat_map(_KeyContainer, _MappedContainer, _Allocator)
_MappedContainer>;
template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator>
- requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
- !__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> &&
- uses_allocator_v<_MappedContainer, _Allocator> &&
+ requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> &&
+ uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
is_invocable_v<const _Compare&,
const typename _KeyContainer::value_type&,
const typename _KeyContainer::value_type&>)
@@ -1162,8 +1160,7 @@ flat_map(_KeyContainer, _MappedContainer, _Compare, _Allocator)
_MappedContainer>;
template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>>
- requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
- !__is_allocator<_MappedContainer>::value &&
+ requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> &&
is_invocable_v<const _Compare&,
const typename _KeyContainer::value_type&,
const typename _KeyContainer::value_type&>)
@@ -1176,7 +1173,7 @@ flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Compare = _Compare()
template <class _KeyContainer, class _MappedContainer, class _Allocator>
requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
- !__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value)
+ !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer>)
flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Allocator)
-> flat_map<typename _KeyContainer::value_type,
typename _MappedContainer::value_type,
@@ -1185,9 +1182,8 @@ flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Allocator)
_MappedContainer>;
template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator>
- requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
- !__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> &&
- uses_allocator_v<_MappedContainer, _Allocator> &&
+ requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> &&
+ uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
is_invocable_v<const _Compare&,
const typename _KeyContainer::value_type&,
const typename _KeyContainer::value_type&>)
@@ -1199,19 +1195,19 @@ flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Compare, _Allocator)
_MappedContainer>;
template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>>
- requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
+ requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>)
flat_map(_InputIterator, _InputIterator, _Compare = _Compare())
-> flat_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>;
template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>>
- requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
+ requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>)
flat_map(sorted_unique_t, _InputIterator, _InputIterator, _Compare = _Compare())
-> flat_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>;
template <ranges::input_range _Range,
class _Compare = less<__range_key_type<_Range>>,
class _Allocator = allocator<byte>,
- class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>>
+ class = __enable_if_t<!__is_allocator_v<_Compare> && __is_allocator_v<_Allocator>>>
flat_map(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_map<
__range_key_type<_Range>,
__range_mapped_type<_Range>,
@@ -1219,7 +1215,7 @@ flat_map(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator(
vector<__range_key_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_key_type<_Range>>>,
vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>;
-template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>>
+template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator_v<_Allocator>>>
flat_map(from_range_t, _Range&&, _Allocator) -> flat_map<
__range_key_type<_Range>,
__range_mapped_type<_Range>,
@@ -1228,11 +1224,11 @@ flat_map(from_range_t, _Range&&, _Allocator) -> flat_map<
vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>;
template <class _Key, class _Tp, class _Compare = less<_Key>>
- requires(!__is_allocator<_Compare>::value)
+ requires(!__is_allocator_v<_Compare>)
flat_map(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_map<_Key, _Tp, _Compare>;
template <class _Key, class _Tp, class _Compare = less<_Key>>
- requires(!__is_allocator<_Compare>::value)
+ requires(!__is_allocator_v<_Compare>)
flat_map(sorted_unique_t, initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_map<_Key, _Tp, _Compare>;
template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Allocator>
diff --git a/libcxx/include/__flat_map/flat_multimap.h b/libcxx/include/__flat_map/flat_multimap.h
index 260d93ed25785..abaacf9e3cda3 100644
--- a/libcxx/include/__flat_map/flat_multimap.h
+++ b/libcxx/include/__flat_map/flat_multimap.h
@@ -928,8 +928,7 @@ class flat_multimap {
};
template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>>
- requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
- !__is_allocator<_MappedContainer>::value &&
+ requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> &&
is_invocable_v<const _Compare&,
const typename _KeyContainer::value_type&,
const typename _KeyContainer::value_type&>)
@@ -942,7 +941,7 @@ flat_multimap(_KeyContainer, _MappedContainer, _Compare = _Compare())
template <class _KeyContainer, class _MappedContainer, class _Allocator>
requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
- !__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value)
+ !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer>)
flat_multimap(_KeyContainer, _MappedContainer, _Allocator)
-> flat_multimap<typename _KeyContainer::value_type,
typename _MappedContainer::value_type,
@@ -951,9 +950,8 @@ flat_multimap(_KeyContainer, _MappedContainer, _Allocator)
_MappedContainer>;
template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator>
- requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
- !__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> &&
- uses_allocator_v<_MappedContainer, _Allocator> &&
+ requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> &&
+ uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
is_invocable_v<const _Compare&,
const typename _KeyContainer::value_type&,
const typename _KeyContainer::value_type&>)
@@ -965,8 +963,7 @@ flat_multimap(_KeyContainer, _MappedContainer, _Compare, _Allocator)
_MappedContainer>;
template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>>
- requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
- !__is_allocator<_MappedContainer>::value &&
+ requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> &&
is_invocable_v<const _Compare&,
const typename _KeyContainer::value_type&,
const typename _KeyContainer::value_type&>)
@@ -979,7 +976,7 @@ flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Compare = _
template <class _KeyContainer, class _MappedContainer, class _Allocator>
requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
- !__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value)
+ !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer>)
flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Allocator)
-> flat_multimap<typename _KeyContainer::value_type,
typename _MappedContainer::value_type,
@@ -988,9 +985,8 @@ flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Allocator)
_MappedContainer>;
template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator>
- requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
- !__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> &&
- uses_allocator_v<_MappedContainer, _Allocator> &&
+ requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> && !__is_allocator_v<_MappedContainer> &&
+ uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> &&
is_invocable_v<const _Compare&,
const typename _KeyContainer::value_type&,
const typename _KeyContainer::value_type&>)
@@ -1002,19 +998,19 @@ flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Compare, _A
_MappedContainer>;
template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>>
- requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
+ requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>)
flat_multimap(_InputIterator, _InputIterator, _Compare = _Compare())
-> flat_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>;
template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>>
- requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
+ requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>)
flat_multimap(sorted_equivalent_t, _InputIterator, _InputIterator, _Compare = _Compare())
-> flat_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>;
template <ranges::input_range _Range,
class _Compare = less<__range_key_type<_Range>>,
class _Allocator = allocator<byte>,
- class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>>
+ class = __enable_if_t<!__is_allocator_v<_Compare> && __is_allocator_v<_Allocator>>>
flat_multimap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_multimap<
__range_key_type<_Range>,
__range_mapped_type<_Range>,
@@ -1022,7 +1018,7 @@ flat_multimap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Alloc
vector<__range_key_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_key_type<_Range>>>,
vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>;
-template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>>
+template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator_v<_Allocator>>>
flat_multimap(from_range_t, _Range&&, _Allocator) -> flat_multimap<
__range_key_type<_Range>,
__range_mapped_type<_Range>,
@@ -1031,11 +1027,11 @@ flat_multimap(from_range_t, _Range&&, _Allocator) -> flat_multimap<
vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>;
template <class _Key, class _Tp, class _Compare = less<_Key>>
- requires(!__is_allocator<_Compare>::value)
+ requires(!__is_allocator_v<_Compare>)
flat_multimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_multimap<_Key, _Tp, _Compare>;
template <class _Key, class _Tp, class _Compare = less<_Key>>
- requires(!__is_allocator<_Compare>::value)
+ requires(!__is_allocator_v<_Compare>)
flat_multimap(sorted_equivalent_t, initializer_list<pair<_Key, _Tp>>, _Compare = _Compare())
-> flat_multimap<_Key, _Tp, _Compare>;
diff --git a/libcxx/include/__flat_set/flat_multiset.h b/libcxx/include/__flat_set/flat_multiset.h
index 44d8af05a56af..65f4161a8c34c 100644
--- a/libcxx/include/__flat_set/flat_multiset.h
+++ b/libcxx/include/__flat_set/flat_multiset.h
@@ -689,7 +689,7 @@ class flat_multiset {
};
template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>>
- requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
+ requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> &&
is_invocable_v<const _Compare&,
const typename _KeyContainer::value_type&,
const typename _KeyContainer::value_type&>)
@@ -697,12 +697,12 @@ flat_multiset(_KeyContainer, _Compare = _Compare())
-> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
template <class _KeyContainer, class _Allocator>
- requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator<_KeyContainer>::value)
+ requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator_v<_KeyContainer>)
flat_multiset(_KeyContainer, _Allocator)
-> flat_multiset<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>;
template <class _KeyContainer, class _Compare, class _Allocator>
- requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
+ requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> &&
uses_allocator_v<_KeyContainer, _Allocator> &&
is_invocable_v<const _Compare&,
const typename _KeyContainer::value_type&,
@@ -711,7 +711,7 @@ flat_multiset(_KeyContainer, _Compare, _Allocator)
-> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>>
- requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
+ requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> &&
is_invocable_v<const _Compare&,
const typename _KeyContainer::value_type&,
const typename _KeyContainer::value_type&>)
@@ -719,12 +719,12 @@ flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare = _Compare())
-> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
template <class _KeyContainer, class _Allocator>
- requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator<_KeyContainer>::value)
+ requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator_v<_KeyContainer>)
flat_multiset(sorted_equivalent_t, _KeyContainer, _Allocator)
-> flat_multiset<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>;
template <class _KeyContainer, class _Compare, class _Allocator>
- requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
+ requires(!__is_allocator_v<_Compare> && !__is_allocator_v<_KeyContainer> &&
uses_allocator_v<_KeyContainer, _Allocator> &&
is_invocable_v<const _Compare&,
const typename _KeyContainer::value_type&,
@@ -733,36 +733,36 @@ flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare, _Allocator)
-> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
template <class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>>
- requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
+ requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>)
flat_multiset(_InputIterator, _InputIterator, _Compare = _Compare())
-> flat_multiset<__iter_value_type<_InputIterator>, _Compare>;
template <class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>>
- requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
+ requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator_v<_Compare>)
flat_multiset(sorted_equivalent_t, _InputIterator, _InputIterator, _Compare = _Compare())
-> flat_multiset<__iter_value_type<_InputIterator>, _Compare>;
template <ranges::input_range _Range,
class _Compare = less<ranges::range_value_t<_Range>>,
class _Allocator = allocator<ranges::range_value_t<_Range>>,
- class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>>
+ class = __enable_if_t<!__is_allocator_v<_Compare> && __is_allocator_v<_Allocator>>>
flat_multiset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_multiset<
ranges::range_value_t<_Range>,
_Compare,
vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>;
-template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_All...
[truncated]
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.